import React from "react";
class Login extends React.Component{

    constructor(){
        super();
        this.state={
            userInfo:{
                username:"admin",
                pwd:"123"
            }
        }
    }
    usernameChange=(e)=>{

        this.setState({userInfo:{...this.state.userInfo,username:e.target.value}});

    }
    pwdChange=(e)=>{
        this.setState({userInfo:{...this.state.userInfo,pwd:e.target.value}});
    }
    login=()=>{
        console.log("登录",this.state.userInfo);
    }
    render(){
        return <div>
      登录
      {this.state.userInfo.username}
      {this.state.userInfo.pwd}
      <div>账号: <input type="text" value={this.state.userInfo.username} onChange={this.usernameChange} /></div>
      <div>密码:<input  value={this.state.userInfo.pwd}  onChange={this.pwdChange} type="text" /></div>
        <div><button onClick={this.login}>登录</button></div>
        </div>
    }


}
export default Login